<template>
    <div id="productIndex">
      <!--
      <product-img :productImg="productInfo.data.link[0].img_src"/>
      <product-video :url="videoSrc" :poster="videoPoster"/>
      <product-img v-for="(list,index) in imgSrc" :key="index" :productImg="list"/>
      -->
      <productImgOrMedia v-for="(list,index) in productInfo_media" :key="index" :type="list.type" :src="list.src"/>
      <purchase-route :LinkList="productInfo_link"/>
    </div>
</template>

<script>
  import PurchaseRoute from '@/components/commonComponents/PurchaseRoute'
  import productImgOrMedia from '@/components/product/productImgOrMedia'
  export default {
        name: "productIndex",
      data(){
        return{
          purchaseRouterVisible:true,
          videoSrc:'',
        }
      },
      components:{
        PurchaseRoute:PurchaseRoute,
        productImgOrMedia:productImgOrMedia,
      },
    computed:{
      productInfo_media:{
        get(){
          let mediaList=this.$store.getters.getProductInfo.media;
          if(mediaList==null&&mediaList===undefined){
            this.purchaseRouterVisible=false;
          }
          return mediaList;
        },
        set(){}
      },
      productInfo_link:{
        get(){
          let linkList=this.$store.getters.getProductInfo.link;
          if(linkList==null&&linkList===undefined){
            this.purchaseRouterVisible=false;
          }
          return linkList;
        }
      },
      lang:{
        get(){
          let storageData = window.sessionStorage.getItem('lang');
          if(this.$store.state.lang!==storageData&&storageData!=='null'){
            this.$store.dispatch('toChangeLang', storageData);    //同步操作
          }
          return this.$store.getters.getLang;
        },
        set(){}
      },
      productId:{
        get(){
          let storageData = window.sessionStorage.getItem('productIndexId');
          if(this.$store.state.productIndexId!=storageData&&storageData!=='null'){
            this.$store.dispatch('toChangeProductIndexId', storageData);    //同步操作
          }
          //productIndex同步操作111
          return this.$store.getters.getProductIndexId;
        },
        set(){}
      }
    },
      methods:{
        //获取产品信息
        getJson(){
          this.$store.dispatch('toChangeLoadIngVisible',true);
          let _this=this;
          this.axios.get(domain.url+'product/api/get_product', {
            params: {
              id:_this.productId,
              language:_this.lang,
              equipment:'mobile'
            }
          })
            .then(function (response) {
              if(response.data.product.title===null||response.data.product.title===undefined){
                _this.$router.push('/MallIndex');
              }
              _this.$store.dispatch('toChangeProductInfo',response.data);
              _this.$store.dispatch('toChangeCurrentPageText',response.data.product.title);
              _this.$store.dispatch('toChangeLoadIngVisible',false);
            })
            .catch(function (error) {
              console.log(error);
            });
        },
      },
      created(){
        this.getJson()
      },
    mounted() {
      this.$emit('changeScroll');
    }
  }
</script>

<style scoped>
  *{
    margin: 0px;
    padding:0px;
  }
  #productIndex{
    width:100%;
    height:100%;
    background: #f5f5f5;
    color:#000000;
  }
</style>
